package com.zhiyou.controller;

import com.zhiyou.service.CodeService;
import com.zhiyou.util.MyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/code")
public class CodeController {

    @Autowired
    MyUtil myUtil;

    @Autowired
    CodeService codeService;

    @RequestMapping("/generate")
    @ResponseBody
    public String verify(String tel, HttpSession session){
        String verifyCode = myUtil.sendSms(tel);
        System.out.println(verifyCode);
        int i = codeService.addVerifyCode(verifyCode,tel);
        return "success";
    }
}
